<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Storage;
class UploaderController extends Controller
{
    //上传图片

    public function webuploader(Request $request){
    	if ($request-> hasFile('file') && $request-> file('file')->isValid()) {
    		
    		$filename = sha1(time().$request->file('file')->getClientOriginalName()).'.'.$request->file('file')->getClientOriginalExtension();
    		// die($filename);

            Storage::disk('public')->put($filename,file_get_contents($request->file('file')->path()));

    		$result = [ 
    			'errCode'  => '0',
    			'errMsg'   => '',
    			'succMsg'  => '文件上传成功！',
    			'path'     => '/storage/'.$filename,

    		];
    	

    	}else{

    		$result = [
    			'errCode'  => '0000001',
    			'errMsg'   => $request ->file('file')->getErrorMessage(),

    		];
    		
    	}

    	return response()-> json($result);



    }
}
